#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QTableView>
#include <QFileDialog>

#include "customer.h"
#include "order.h"
#include "dbconnection.h"
#include "backupsystem.h"

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

    Customer _customer;
    BackupSystem _backupSystem;
    Order _order;
    QSqlQueryModel *_customersModel;
    QSqlQueryModel *_ordersModel;
    QString _dbUser;
    QString _dbUserPass;
    QString _dbName;
    void centerOnScreen();

protected slots:

    void loadBackup();
    void createBackup();

    void loadDb();

    void loadCustomers();
    void loadOrders();

    void showCustomersTable();
    void showOrdersTable();

    void editCustomer();
    void deleteCustomer();

    void addOrder();
    void editOrder();
    void deleteOrder();

    void filterCustomers();
    void filterOrders();
    void filter(QTableView* &tableView, QSqlQueryModel* model, QString column, QString value);
};

#endif // MAINWINDOW_H
